package com.ruoyi.index.controller;

import com.ruoyi.index.dto.GoodsCategoryDto;
import com.ruoyi.index.service.GoodsCategoryService;
import com.ruoyi.index.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/index/category")
public class GoodsCategoryController {
    @Autowired
    private GoodsCategoryService goodsCategoryService;

    @RequestMapping("/selectGoodsCategory/{isActive}")
    public Result selectGoodsCategory(@PathVariable Integer isActive){
        List<GoodsCategoryDto> categoryList = goodsCategoryService.selectGoodsCategory(isActive);
        return Result.success().put("categoryList",categoryList);
    }
    @RequestMapping("/selectGoodsCategoryId/{categoryId}")
    public Result selectGoodsCategoryId(@PathVariable Integer categoryId) {
        GoodsCategoryDto categoryDto = goodsCategoryService.selectGoodsCategoryId(categoryId);
        return Result.success().put("categoryDto",categoryDto);
    }
    @PostMapping("/selectLikeGoodsCategory")
    public Result selectLikeGoodsCategory(@RequestParam(name = "keyword") String goodsName){
        List<GoodsCategoryDto> goodsLike = goodsCategoryService.selectLikeGoodsCategory(goodsName);
        return Result.success().put("goodsLike",goodsLike);
    }

}
